package views
{
	import inerface.ISysRecommendPathListPanel;
	
	import main.ViewSubBase;
	
	import panel.recommendPathList.SysRecommendPathListPanel;
	
	import struct.RecommendPath;
	
	public class SysRecommendPathView extends ViewSubBase
	{
		private var _panel:ISysRecommendPathListPanel;
		
		public function SysRecommendPathView()
		{
		}
		
		public override function show():void
		{
			data.viewSpot.loadViewSpotData(function():void {});
			data.viewSpot.loadEatData(function():void {});
			data.viewSpot.loadHotelData(function():void {});
			data.viewSpot.loadShopData(function():void {});
			
			data.xmlLoaderManager.recommendPathXml.initThis(render);
		}
		
		protected override function render():void
		{
			if(!_panel){
				_panel = new SysRecommendPathListPanel;
				
				_panel.onShowDetail = showPath;
				_panel.showChoosenPath = showChoosen;
				
				_panel.init(view.layout.stage,view.resourceLoader,view.lang,view.uri);
			}
			
			_panel.changeData = data.sysRecommendPath.pathList;
			
			this.addView(_panel);
		}
		
		public override function clear():void
		{
			if(_panel){
				_panel.clear();
				_panel = null;
			}
		}
		
		public override function close():void
		{
			view.layout.closeView(this);
		}
		
		public function showChoosen():void
		{
//			view.selectPath.titleStr = "我的路线";
//			view.selectPath.pathList = data.choosePath.elementList;
//			view.selectPath.show();
			
			view.selfPathList.show();
		}
		
		public function showPath(obj:RecommendPath):void
		{
			for(var i:int = 0;i < obj.info.length;i++){
				for(var j:int = 0;j < obj.info[i].length;j++){
					obj.info[i][j].initThis();
				}
			}
			
			view.sysRecommendPathInfo.info = obj;
			view.sysRecommendPathInfo.show();
		}
	}
}